/**
 * JAVACC DEMO 1.0
 */
package com.apache.portal.tags;

import com.apache.api.vo.ResultEntity;
import com.apache.portal.common.util.PortalPubFactory;
import com.apache.rpc.common.LoadRpcService;
import com.apache.tools.ConfigUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import java.util.HashMap;
import java.util.Map;

/**
 * description:  根据项目ID查询项目基本信息
 *
 * @author cbqiu 创建时间：2017-6-3
 */
@SuppressWarnings("serial")
public class ProInfoTag extends TagSupport {

    public int doStartTag() throws JspException {
        try {
            HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
            ResultEntity entity = null;
            Map<String, Object> params = new HashMap<String, Object>();
            String proId = request.getParameter("proId");
            if (proId != null && !"".equals("proId")) {
                params.put("proId", proId);

                String sysPass = ConfigUtil.getInstance().interfacePass();
                params.put("sysPass", sysPass);
                entity = LoadRpcService.service().doServiceClient("nytService", "proEntity", params,
                        PortalPubFactory.getInstance().getRpcInfo("net"));
                if ("true".equals(entity.getResult()) && null != entity.getEntity()) {
                    Map<String, Object> resMap = (Map<String, Object>) entity.getEntity();
                    //					TrpPro trpPro = new TrpPro();
                    //					String proStatus = String.valueOf(resMap.get("proStatus"));
                    //					String expStatus = String.valueOf(resMap.get("expStatus"));
                    //					String dealWay = String.valueOf(resMap.get("dealWay"));
                    //					String auditId = String.valueOf(resMap.get("auditId"));
                    //					String qualityFlag = String.valueOf(resMap.get("qualityFlag"));
                    //					trpPro.setProStatus(proStatus);
                    //					trpPro.setExpStatus(expStatus);
                    //					trpPro.setDealWay(dealWay);
                    //					trpPro.setAuditId(auditId);
                    //					trpPro.setQualityFlag(qualityFlag);
                    request.setAttribute("trpPro", resMap);
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
            return super.SKIP_BODY;
        }
        return super.EVAL_BODY_INCLUDE;
    }

}
